#include "DM.h"
#include "message.h"


//----------------------------------------------------------------------------------------------------------//
Node_C::Node_C(string p_strName) : 
    _nId(), _strName(p_strName), _pFromWire(NULL), _vToWire(), _fParasiticCap(0.0)//, _fEffCap(-1)
{
    this->_pTimingInfo = new TimingInfo_S;
}
//----------------------------------------------------------------------------------------------------------//
Node_C::Node_C(string p_strName, float p_fParasiticCap) : 
    _nId(), _strName(p_strName), _pFromWire(NULL), _vToWire(), _fParasiticCap(p_fParasiticCap)//, _fEffCap(-1)
{
    this->_pTimingInfo = new TimingInfo_S;
}
//----------------------------------------------------------------------------------------------------------//
Node_C::~Node_C() 
{
    delete this->_pTimingInfo;
}
//----------------------------------------------------------------------------------------------------------//
void Node_C::dump(Dumper* p_pDumper)
{
    //name
    p_pDumper->write("%s ID:%d ",this->getName().c_str(),this->getId());
    //type
    if(Node_C::ePin==this->getType()){
        p_pDumper->write("(Pin)\n");
        PinNode_C* pPinNode = static_cast<PinNode_C*> (this);
        if(PinNode_C::eInput==pPinNode->getDir()){
            p_pDumper->write("dir (in) of Inst: %s\n",pPinNode->getInst()->getName().c_str());
        } else {
            p_pDumper->write("dir (out) of Inst: %s\n",pPinNode->getInst()->getName().c_str());
        }
    } else if(Node_C::eInter==this->getType()){
        p_pDumper->write("(Inter)\n");
    } else if(Node_C::ePI==this->getType()){
        p_pDumper->write("(PI)\n");
    } else {
        p_pDumper->write("(PO)\n");
    }
    //cap 
    Wire_C* pFromWire = this->getFromWire();
    //from_node res
    p_pDumper->write("%.3f\n",this->getParasiticCap());
    p_pDumper->write("from ");
    if(pFromWire){
        p_pDumper->write("%s %.3f",pFromWire->getFromNode()->getName().c_str(),pFromWire->getRes());
    }
    p_pDumper->write("\n");
    //to_node res
    const vector<Wire_C*>& vToWire = this->getToWire();
    for(unsigned int iWire=0;iWire<vToWire.size();++iWire){
        Wire_C* pToWire = vToWire[iWire];
        p_pDumper->write("to %s %.3f\n",pToWire->getToNode()->getName().c_str(),pToWire->getRes());
    }
    p_pDumper->write("\n");
}
//----------------------------------------------------------------------------------------------------------//

